package tasks;

public class JpbTask implements Runnable{
    private javax.swing.JProgressBar jpb;
    private long milliSec;

    public JpbTask(javax.swing.JProgressBar jProgressBar, long sleep){
        jpb = jProgressBar;
        milliSec = sleep;
    }//JpbTask Constructor

    public void run(){
        try{
            for(int i = 1; i <= jpb.getMaximum(); i++){
                jpb.setValue(i);
                jpb.setString(String.format("%.of%%", ((i + 1.0)/jpb.getMaximum()) * 100));
                Thread.sleep(milliSec);
            }//for
        }//try
        catch(InterruptedException ie){
            ie.printStackTrace();
        }//catch
    }//run()
}//JpbTask